//获取物料信息
import api from '@/api/index.ts';
import { goodStore } from '@/store/index';
export const getGood = async () => {
  const info = goodStore();
  if (info.goods.length > 0) return;
  await api.Goods.GetPageGoodsSpecificationView({
    queryDataBaseFiled: 'specificationCode',
    likeWords: '',
    pageIndex: 1,
    pageSize: 99999,
    groupCode: '',
    supplierCode: '',
    state: -1,
    isShowDisabled: 0,
  }).then((res: any) => {
    info.goods = res.list.map((el: any) => ({
      goodsCode: el.goodsCode, //物料编码
      goodsName: el.goodsName, //物料名称
      specificationCode: el.specificationCode, //规格编号
      specificationName: el.specificationName, //规格名称
      supplierCode: el.supplierCode, //供应商编码
      supplierName: el.supplierName, //供应商名称
      goodsGroupCode: el.goodsGroupCode, //	物料分组编码
      goodsGroupName: el.goodsGroupName, //物料分组名称
      goodsTypeName: el.goodsTypeName, //物料类型名称
      goodsTypeCode: el.goodsTypeCode, //物料类型编码
      specificationJsValue: el.specificationJsValue, //	转换比例
      goodsUnit: el.goodsUnit, //	物料单位
      goodsPrice: el.goodsPrice, //	含税单价
      goodsPriceBeforeTax: el.goodsPriceBeforeTax, //	未税单价
      totalStockQuantity: el.totalStockQuantity, //	总库存
      //库存明细
      details: el.details,
    }));
  });
};
export const getProduce = async (produceTaskBillNo: string, fun?: Function) => {
  await api.ProductionBusniess.GetMatchPageProduceTaskBills({
    pageIndex: 1,
    pageSize: 1,
    queryDataBaseFiled: 'produceTaskBillNo',
    likeWords: produceTaskBillNo,
    isShowCancelBills: false,
    isShowCompleteBills: true,
    produceBillType: 0,
    produceBillState: -1,
    taskProduceState: -1,
    materialState: -1,
    dataBillState: -2,
    beginTime: '',
    endTime: '',
  }).then((res: any) => {
    if (fun && typeof fun === 'function' && res.list.length > 0) {
      fun(res.list[0]);
    }
  });
};
